<template>
  <div :class="classObj" class="app-wrapper">
    <div v-if="device === 'mobile' && sidebar.opened" class="drawer-bg" @click="handleClickOutside"></div>
    <Header />
    <div class="main-content">
      <Sidebar class="sidebar-container" />
      <div :class="{ hasTagsView: needTagsView }" class="main-container">
        <div :class="{ 'fixed-header': fixedHeader }">
          <TagsView v-if="needTagsView" />
        </div>
        <AppMain />
        <!-- <div class="pdt-footer">
          <Footer />
        </div> -->
      </div>
    </div>
  </div>
</template>

<script>
import TagsView from "./components/TagsView/index";
import Header from "./components/Header/index";
import Footer from "./components/Footer/index";
import Navbar from "./components/Navbar.vue";
import { AppMain, Sidebar, TabsBar } from "./components";
import ResizeMixin from "./mixin/ResizeHandler";
import { mapState } from "vuex";
export default {
  name: "Layout",
  components: {
    AppMain,
    Sidebar,
    Header,
    Footer, TabsBar, Navbar, TagsView
  },
  mixins: [ResizeMixin],
  computed: {
    ...mapState({
      sidebar: (state) => state.app.sidebar,
      device: (state) => state.app.device,
      needTagsView: (state) => state.settings.tagsView,
      fixedHeader: (state) => state.settings.fixedHeader
    }),
    classObj () {
      return {
        hideSidebar: !this.sidebar.opened,
        openSidebar: this.sidebar.opened,
        withoutAnimation: this.sidebar.withoutAnimation,
        mobile: this.device === "mobile"
      };
    }
  },
  methods: {
    handleClickOutside () {
      this.$store.dispatch("app/closeSideBar", { withoutAnimation: false });
    }
  }
};
</script>

<style lang="scss" scoped>
@import "~@/styles/mixin.scss";
@import "~@/styles/variables.scss";

.app-wrapper {
  @include clearfix;
  position: relative;
  height: 100%;
  width: 100%;
  // min-width: 1024px;
  // min-width: 1920px;

  &.mobile.openSidebar {
    position: fixed;
    top: 0;
  }
}

.drawer-bg {
  background: #000;
  opacity: 0.3;
  width: 100%;
  top: 0;
  height: 100%;
  position: absolute;
  z-index: 999;
}

.fixed-header {
  // width: 100%;
  width: calc(100% - 20px);
  margin-top: $hamburgerToHeaderHeight;
  margin-left: 10px;
  transition: width 0.28s;
}

.hideSidebar .fixed-header {
  width: 100%;
}

.mobile .fixed-header {
  width: 100%;
}

.main-content {
  display: flex;
  width: 100%;
  height: calc(100% - #{$headerHeight});
  background-color: $appMainBgColor;
  font-size: 14px;
}

.pdt-footer {
  padding-top: 0px;
}
</style>

<style lang="scss">
.myClass {
  border: 1px solid #00a1c2;
  // background-color: rgba($color: #00a1c2, $alpha: 0.5);

  .el-message-box__title {
    color: #fff;
    background-color: #237FC3;
    padding: 15px;
  }

  .el-message-box__message {
    color: #000;
  }
}
</style>
